package com.ht.rules;

import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;

import javax.sound.midi.MidiDevice.Info;

import org.drools.core.impl.StatefulKnowledgeSessionImpl;
import org.drools.core.io.impl.UrlResource;
import org.kie.api.KieBase;
import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.StatelessKieSession;
import org.springframework.context.support.ClassPathXmlApplicationContext;




public class RuleTest {

	
	public static  void main(String [] args) throws IOException{

		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("com/ht/rules/drools-spring.xml");
		StatefulKnowledgeSessionImpl impl= (StatefulKnowledgeSessionImpl) context.getBean("ksession1");
		KieBase kbase = impl.getKieBase();
		KieSession ksession = kbase.newKieSession();
	    

		
	    BaoXianInfo infos = new BaoXianInfo();
	    infos.setCompanyName("BOCG");
	    infos.setInsuredSex("M");
	    infos.setPlanyear(1);
	    infos.setPerm(new BigDecimal(10000));
	    ksession.insert(infos);
	    ksession.fireAllRules();
	} 
	public   void test()  {

		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("com/ht/rules/drools-spring.xml");
		StatefulKnowledgeSessionImpl impl= (StatefulKnowledgeSessionImpl) context.getBean("ksession1");
		KieBase kbase = impl.getKieBase();
		KieSession ksession = kbase.newKieSession();
	    

		
	    BaoXianInfo infos = new BaoXianInfo();
	    infos.setCompanyName("BOCG");
	    infos.setInsuredSex("M");
	    infos.setPlanyear(1);
	    infos.setPerm(new BigDecimal(10000));
	    ksession.insert(infos);
	    ksession.fireAllRules();
	} 
}
